package test_package;

public class Test5 {
    int num = 1;
    public static void main(String[] args) throws InterruptedException {
        Test5 t = new Test5();
        new Thread(()->{
            if (t.num <= 0) {
                System.out.println(Thread.currentThread().getName() + " if：" + t.num);
            } else {
                System.out.println(Thread.currentThread().getName() + " else：" + t.num);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + " else：" + t.num);
            }
        },"线程1").start();

        new Thread(()->{
            if (t.num <= 0) {
                System.out.println(Thread.currentThread().getName() + " if：" + t.num);
            } else {
                System.out.println(Thread.currentThread().getName() + " else" + t.num);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + " else：" + t.num);
            }
        },"线程2").start();
        Thread.sleep(10);
        t.num--;
        Thread.sleep(200);
        t.num--;


    }
}
